package gui;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import Lexicon.Chars;
public class JArabicKB extends JPanel implements ActionListener
{
	/**
	 * Arabic Keyboard panel
	 */
	private static final long serialVersionUID = 1L;
	private JButton [] arkeys  ;
	String character ;
	public JArabicKB()
	{
		arkeys = new JButton[36];
		//construct components
		for(int j = 0 ;j<36 ;j++)
		{
			arkeys[j]= new JButton();
			arkeys[j].setText("<HTML><FONT color=blue size = 6>"+
					Character.toString(Chars.CHAR_SET[j])
					+"</FONT></HTML>"
					);
			arkeys[j].setToolTipText(Character.toString(Chars.CHAR_SET[j]));
			//arkeys[i].addActionListener(new A
				//	)
			setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		}
		
		//adjust size and set layout
		setPreferredSize (new Dimension (210, 500));
		//setLocation(/*new TranslationFrame().getXLocation()+*/700 ,new TranslationFrame().getYLocation());
		GridLayout layout = new GridLayout(9,4, 3, 3);
		setLayout (layout);setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
		//add components
		for(int i = 0 ;i<36 ;i++)
		{
			add(arkeys[i]);
			arkeys[i].addActionListener(this);
		}
	}
	/*Unit testing
	 * 
	 
	 throws UnsupportedLookAndFeelException
	{
		JFrame frame = new JFrame ("On-Screen ArabicKeyboard");
		UIManager.setLookAndFeel(new SubstanceLookAndFeel());
		frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
		//use thisline in your application
		JArabicKB arKB = new JArabicKB();
		frame.getContentPane().add (arKB);
		frame.pack();
		frame.setVisible (true);
		setDefaultLocale(new Locale("ar"));
	}*/
	public void actionPerformed(ActionEvent action) {
		for(int k= 0 ;k< 36 ; k++)
		if(action.getSource() == arkeys[k])
		{
			ArMT.appendToInput(arkeys[k].getToolTipText());
		}
	}
}

